package com.right.health.app.utils;

import android.util.Base64;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;

/*
 * Created by hopeliao on 2019-11-30
 *
 */
public class Base64Utils {

    public static String encodeBase64File(String path) throws Exception {
        return encodeBase64File(new File(path));
    }

    public static String encodeBase64File(File file) throws Exception {
        FileInputStream inputFile = new FileInputStream(file);
        byte[] buffer = new byte[(int) file.length()];
        inputFile.read(buffer);
        inputFile.close();
        return Base64.encodeToString(buffer, Base64.DEFAULT);
    }
}
